package edu.java.texbooks.scjp.threads.test10;

public class Test {
	public static void main(String[] args) {
		// testIsAliveMethod();
		testgetStateMethod();
	}

	public static void testIsAliveMethod() {
		MyThread mt1 = new MyThread();
		MyThread mt2 = new MyThread();

		mt1.start();
		System.out.println("Thread mt1 is alive: " + mt1.isAlive());

		System.out.println("Thread mt2 is alive: " + mt2.isAlive());
		mt2.start();
	}

	public static void testgetStateMethod() {
		MyThread mt1 = new MyThread();

		// print all possible states
		Thread.State[] threadStates = Thread.State.values();
		for (Thread.State state : threadStates) {
			System.out.println(state);
		}

		Thread.State currentThreadState;

		// the state of thread before calling of start() method
		currentThreadState = mt1.getState();
		System.out.println("Thread state before start() method: "
				+ currentThreadState.toString());

		mt1.start();
		System.out.println("Thread state after calling start() method: "
				+ mt1.getState());

	}
}
